package com.burstly.lib.feature;

import android.content.Context;
import com.burstly.lib.feature.apptracker.IAppTracker;
import com.burstly.lib.feature.currency.ICurrencyManager;
import com.burstly.lib.feature.dtracker.IDownloadTracker;
import com.burstly.lib.feature.networks.IAdaptorFactory;
import com.burstly.lib.util.LoggerExt;
import org.springframework.context.support.AbstractApplicationContext;

public final class FeatureFactory
{
  private static final String APPTRACK_FEATURE_ID = "apptracking";
  private static final String CONTEXT_NAME = "config.xml";
  private static final String CURRENCY_FEATURE_ID = "currency";
  private static final String DEBUG_FEATURE_ID = "debug";
  private static final String DTRACKER_FEATURE_ID = "dtracker";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = "FeatureFactory";
  private static AbstractApplicationContext sContext;

  public static IAdaptorFactory getAdaptorFactoryFeature(String paramString)
  {
    return (IAdaptorFactory)getFeature(paramString, IAdaptorFactory.class);
  }

  public static IAppTracker getAppTrackerFeature()
  {
    return (IAppTracker)getFeature("apptracking", IAppTracker.class);
  }

  public static ICurrencyManager getCurrencyFeature()
  {
    return (ICurrencyManager)getFeature("currency", ICurrencyManager.class);
  }

  public static IDownloadTracker getDTrackFeature()
  {
    return (IDownloadTracker)getFeature("dtracker", IDownloadTracker.class);
  }

  private static <T> T getFeature(String paramString, Class<T> paramClass)
  {
    try
    {
      Object localObject = sContext.getBean(paramString, paramClass);
      return localObject;
    }
    catch (Exception localException)
    {
      LoggerExt localLoggerExt = LOG;
      Object[] arrayOfObject = new Object[2];
      arrayOfObject[0] = paramString;
      arrayOfObject[1] = paramClass.getName();
      localLoggerExt.logWarning("FeatureFactory", "Error retrieving feature with id:{0} and class name: {1}. Check configuration file.", arrayOfObject);
      LOG.logThrowable("FeatureFactory", localException);
    }
    return null;
  }

  public static void init(Context paramContext)
  {
    if (sContext == null)
    {
      LOG.logDebug("FeatureFactory", "Initilizing feature factory...", new Object[0]);
      sContext = new LazyXmlApplicationContext(paramContext, "config.xml");
      LOG.logDebug("FeatureFactory", "Initilizing feature factory completed.", new Object[0]);
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.feature.FeatureFactory
 * JD-Core Version:    0.6.2
 */